<%@ page language="java"  pageEncoding="utf-8"%>
<%@ page import="com.ejoysoft.wlanyz.business.Ac,com.ejoysoft.wlanyz.business.Task,com.ejoysoft.wlanyz.business.Testtemplate,java.util.Iterator,java.util.Set,java.util.ArrayList,java.util.Map,com.ejoysoft.wlanyz.business.Index,com.ejoysoft.wlanyz.business.Ap,com.ejoysoft.common.Constants,com.ejoysoft.common.exception.NoRightException" %>
<%@ page import="com.ejoysoft.wlanyz.business.Ac,java.util.Iterator,java.util.Set,java.util.ArrayList,java.util.Map,com.ejoysoft.wlanyz.business.Ap" %>
<%@page import="java.util.Vector"%>
<%@ include file="../include/jsp/head.jsp"%>


<%
if(!globa.userSession.hasRight("10020"))
      throw new NoRightException("用户不具备操作该功能模块的权限，请与系统管理员联系！");
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String classOneAc = ParamUtil.getString(request,"strClassOneHP","").trim();//获取一级热点;
String classTwoAc = ParamUtil.getString(request,"strHotPotName","").trim();//获取二级热点;
Task obj1=new Task(globa);
Testtemplate obj2=new Testtemplate(globa);//用于查找任务类型
Vector<Testtemplate> vctObj2=obj2.listTask();
ArrayList<Object[]> classOneList = obj1.getAllclassoneByName("");

%> 

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
<link href="../css/main.css" rel="stylesheet" type="text/css" />
<script src="../scripts/jsframework.js"></script>
<script language="JavaScript" src="../js/jquery-1.4.1.min.js"></script>
<script src="../scripts/jquery-1.4.1.min.js"></script>
<script src="../include/DatePicker/WdatePicker.js"></script>
<script src="../include/js/chkFrm.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
body {
	background-color: #f2f8ff;
}
.sel1{ width:160px;}
.STYLE1 {color: #FF0000}
a{ font-size:12px; color:#214263; text-decoration:none; }
a:hover{ font-size:12px; color:#ffffff; background-color:#ff9900; text-decoration:none;display:block;} 
</style>
   <%
	 Ac obj6 = new Ac(globa);
	 ArrayList<String> listCities = obj6.listAllCitys(""); 
	 if(listCities != null)
	 {
	%>

	<script language="javascript"> 

					  var data={};
					  
					  
					  data["-1_jiangsu"] = "text:安徽省;url:javascript:void(1);target:mainFrame;";
								<%
			 						for(int k=0;k<listCities.size();k++)
			 						{
										String cityName = listCities.get(k);
										ArrayList<String> listCountries = obj6.listCountriesOfCity(" where strCity='"+cityName+"'");
										%>
										 	 data['<%="jiangsu_"+cityName+"cityName"%>'] = "text:"+'<%=cityName%>'+";target:mainFrame;";
										<%
										if(listCountries != null )
										{
											for(int m=0;m<listCountries.size();m++)
											{
												String countryName = listCountries.get(m);
												ArrayList<String> listClassOneAcs = obj6.listClassOneAcs(" where strCity='"+cityName+"' and strTown='"+countryName+"'");
										%>
										 		 data['<%=cityName+"cityName_"+countryName+"countyName"%>'] = "text:"+'<%=countryName%>'+";target:mainFrame;";
										<%
										if(listClassOneAcs !=null)
										{
												for(int m1 = 0 ;m1<listClassOneAcs.size();m1++)
												{
													String oneAcName = listClassOneAcs.get(m1);
													
												 	String tempString ="namestart"+oneAcName+"nameendimport";
												 	
													
										%>
											 		 data['<%=countryName+"countyName_"+tempString%>'] = "text:"+'<%=oneAcName%>'+";target:mainFrame;";
										<%	
												}
											}
										  }
										}		 						
			 						}
			 			%>
			 					  
									
</script>
	<%
	 }
	%>
	<%
	 %>
<script language="javascript">
    //****************************************************************************** 
  
  

var isIe=(document.all)?true:false;
//设置select的可见状态
var j=1;
function setSelectState(state)
{
var objl=document.getElementsByTagName('select');
for(var i=0;i<objl.length;i++)
{
//alert();
objl[i].style.visibility=state;
}
}

//弹出方法
function showMessageBox(e,wWidth,wHeight)
{ 

	closeWindow();
	var bWidth=parseInt(document.documentElement.scrollWidth);
	var bHeight=parseInt(document.documentElement.scrollHeight);
	if(isIe){ 
		setSelectState('hidden');
	}
	var back=document.createElement("div");
	back.id="back";
	var styleStr="top:0px;left:0px;position:absolute;background:#666;width:"+bWidth+"px;height:"+bHeight+"px;";
	styleStr+=(isIe)?"filter:alpha(opacity=0);":"opacity:0;";
	back.style.cssText=styleStr;
	document.body.appendChild(back);
	showBgSuddenlly(back,50);//背景突然变暗
	//showBgGradually(back,50);//背景逐渐变暗
	var mesW=document.createElement("div");
	//---------------------

	//---------------------
	mesW.id="mesWindow";
	mesW.className="mesWindow";  
    Using("System.Web.UI.WebControls.MzTreeView");
    var a = new MzTreeView("");
    a.dataSource = data ;
    a.autoSort=true;
    a.useCheckbox=true
    a.canOperate=true;   // alert(a.render())
    var tempString="";
	 tempString =  tempString+ "<div id='contentDiv' class='mesWindowTop'><table width='100%' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='8FA6BD' >"+
                                    "<tr>  <td class='layertit'><table width='100%' height='32' border='0' cellpadding='0' cellspacing='0'><tr>";
	tempString  = tempString+ "<td class='tit'><strong><font style='font-size:14px' color='#FFFFFF'>热点选择  </font></strong></td>" + 
						                             	"<td swidth='28%' align='right' class='layri'onclick='closeWindow();'style='cursor:hand'><img src='../images/layer_gb.jpg'  title='关闭窗口'  /><font  color='#FFFFFF'>关闭</font></td>";
	tempString = tempString + "</tr></table></td></tr><tr> <td background='../images/layer_bg.jpg' class='listd'><table id='resultTable' width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>"+
						            "<tr> <td> "+a.render()+"</td></tr>" + 
						            "<tr><td><img src='../images/layer_bot.png' width='400' height='6' /></td></tr></table></td></tr></table></td></tr> </table> </div>";
				          
	mesW.innerHTML=tempString; 
	   var   t=e.offsetTop; 
	   var   l=e.offsetLeft; 
	  //  alert(e.offsetTop);
	   while(e=e.offsetParent){ 
	        t+=e.offsetTop; 
	        l+=e.offsetLeft; 
	        } 
	var leftPoint = l;
	var topPoint = t;
	
	styleStr="left:"+leftPoint+"px;top:"+topPoint+"px;position:absolute;width:"+wWidth+"px;";
	mesW.style.cssText=styleStr;
	document.body.appendChild(mesW); 
    a.expandLevel(2);//梅花树展开
	
}
//让背景渐渐变暗
function showBgGradually(obj,endInt)
{
if(isIe)
{
	obj.filters.alpha.opacity+=1;
	if(obj.filters.alpha.opacity<endInt)
	{
		setTimeout(function(){showBgGradually(obj,endInt)},5);
	}
}else{
	var al=parseFloat(obj.style.opacity);
	al+=0.01;
	obj.style.opacity=al;
	if(al<(endInt/100))
	{
		setTimeout(function(){showBgGradually(obj,endInt)},5);}
	}
}

//让背景突然变暗
function showBgSuddenlly(obj,endInt)
{
	if(isIe)
	{
		obj.filters.alpha.opacity += endInt;//背景突然变暗
	}else{
		var al=parseFloat(obj.style.opacity);
		al+=0.01*endInt;
	 	obj.style.opacity=al;//背景突然变暗
		 
	}
}
//关闭窗口
function closeWindow()
{


if(document.getElementById('back')!=null)
{
document.getElementById('back').innerHTML="";
document.getElementById('back').parentNode.removeChild(document.getElementById('back'));


}
if(document.getElementById('mesWindow')!=null)
{
document.getElementById('mesWindow').innerHTML="";
document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));

}

if(isIe){
	 setSelectState('');
	}
	
}

//弹出窗口
function testMessageBox(e)
{

	//var objPos = mousePosition(ev); 
	//showMessageBox(objPos,400,200);
	showMessageBox(e,400,200);

}
  
   function getAcName1()
 {
 
    var classoneac1 = document.getElementById("strClassOneHP").value ;
   	$("#strHotPotName").html("");
	$("#strHotPotName").append("<option value=''>- - - - -请选择- - - - -</option>");
 
 	<%
 		
 		for (int j = 0; j <  classOneList.size(); j++) {
			String hotspotone = (String)(classOneList.get(j)[0]);//
			
			ArrayList<Ac> classtwoac = (ArrayList<Ac>)(classOneList.get(j)[1]);
			%>
			
			if(classoneac1 != null && classoneac1!="" && classoneac1 == '<%=hotspotone%>')
			{
			<%
			  for(int i=0;i<classtwoac.size();i++){
			  Ac acObj = classtwoac.get(i);
			%> 
				$("#strHotPotName").append("<option value='<%=acObj.getStrId()%>'><%=acObj.getStrHotPotName()%></option>");
			<%
			  }
			%>
			} 
			<%
		}
 		%>
 }
  
  
  
  
  
  
  //*******************************************************************************************
	function openwindow(){ 
	var temp= "";
	temp=window.open("task_addchooseman.jsp?random="+Math.random(),"", "width=700,height=500,top=100,left=400,scrollbars=yes,status=no,resizable=no,center=yes"); 
//	document.all.strProjectsName.value=""; 
	//if(temp!=null){
//		subtemp=temp.substring(9);
	//	document.all.strProjectsName.value += subtemp; 
		
//	}
	
} 


	
    function chkFrm() {
    if(trim(frm.strTaskMan.value)=="") {
       alert("请选择测试人！！！")
       frm.strTaskMan.focus();
       return false;
        }
        
       if(trim(frm.strTaskPhone.value)=="") {
       alert("请选择测试人手机号！！！")
       frm.strTaskPhone.focus();
       return false;
        }  
        if(trim(frm.strTaskName.value)=="") {
       alert("请输入任务名称！！！")
       frm.strTaskName.focus();
       return false;
        } 
        if(trim(frm.strTaskType.value)=="") {
       alert("请输入任务类型！！！")
       frm.strTaskType.focus();
       return false;
        } 
        if(trim(frm.strNetType.value)=="") {
       alert("请输入网络类型！！！")
       frm.strNetType.focus();
       return false;
        } 
        if(trim(frm.strTestCount.value)=="") {
       alert("请输入测试次数！！！")
       frm.strTestCount.focus();
       return false;
        } 
        if(Math.floor(trim(frm.strTestCount.value))!=trim(frm.strTestCount.value)) {
            alert("测试次数请输入整数！！！")
            frm.strTestCount.focus();
            return false;
            }
        if(trim(frm.strPingAddr.value)=="") {
       alert("请输入ping地址！！！")
       frm.strPingAddr.focus();
       return false;
        } 
         if(trim(frm.strFtpAddress.value)=="") {
       alert("请输入ftp地址！！！")
       frm.strFtpAddress.focus();
       return false;
        } 
         if(trim(frm.strHttpSite.value)=="") {
       alert("请输入http地址！！！")
       frm.strHttpSite.focus();
       return false;
        } 
         if(trim(frm.strHotPotName.value)=="") {
       alert("请选择热点！！！")
       frm.strHotPotName.focus();
       return false;
        }  
         if((frm.dtStartTime.value)>(frm.dtEndTime.value))
        {
          alert("起始时间大于终止时间，请重新输入");
          frm.dtStartTime.focus();
          return false;
        }           
  		frm.submit();         
    }
</script>
</head>


<body>

<form name="frm" method=post action="task_act.jsp"  >

<input type="hidden" name="<%=Constants.ACTION_TYPE%>" value="<%=Constants.ADD_STR%>"></input>

<div class="lf_list">
<table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">

  <tr>
    <td height="30"><img src="../images/ri_list.jpg" width="14" height="14" align="bottom" />&nbsp;<font size="2px">您现在所在的位置：</font><font color="#0e7cc9" size="2px">任务管理 </font><font size="2px">&gt; 任务信息管理</font><font size="2px">&gt; 添加任务</font></td>
  </tr>
</table>
<table id="tb" width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
 <tr> <td class="listtit1"align="left">&nbsp; &nbsp;<font size="2px"> 添加任务</font></td>
</tr>
 
  <tr>
    <td bgcolor="#FFFFFF" class="listd" style="border-left:1px solid #dddddd;border-right:1px solid #dddddd;">&nbsp;
   
    <table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">        
     <tr>
       <td >
       <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" style="margin:10px 0px 2px 0px;">
       <tr>
	     

		</tr>
       </table></td></tr>

          <tr>
            <td>
            <table width="80%" border="0" cellspacing="0" cellpadding="0">
            <tr>
            <td width="50"></td>
            <td>
             <table width="353" border="0" cellspacing="0" cellpadding="0" height="484">
		             <tr>
		               <td width="35%" height="30" align="right" class="left_txt2"><font size="2px">测试人：</font></td>
		                <td width="3%">&nbsp;</td>
		                <td width="40%" align="left"><input type="text"  class="ipt" name="strTaskMan" id="strTaskMan"/>
		                </td> 
		            </tr>
		             <tr>
		               <td width="35%" height="30" align="right" class="left_txt2"><font size="2px">测试手机号：</font></td>
		                <td width="3%">&nbsp;</td>
		                <td width="40%" align="left"><input type="text"  class="ipt" name="strTaskPhone" id="strTaskPhone"/>
		                </td> 
		            </tr>
		             <tr>
		               <td width="35%" height="30" align="right" class="left_txt2"><font size="2px">任务描述：</font></td>
		                <td width="3%">&nbsp;</td>
		                <td width="40%" align="left"><input type="text"  class="ipt" name="strTaskDes" id="strTaskDes"/>
		                </td> 
		            </tr>
					<tr>
		               <td width="35%" height="30" align="right" class="left_txt2"><font size="2px">ping地址：</font></td>
		                <td width="3%">&nbsp;</td>
		                <td align="left">
		                      <textarea id="strPingAddr" name="strPingAddr"   class="input_box" rows="5" cols="25"/></textarea>
		            </td> </tr>
		            <tr>
		               <td width="35%" height="30" align="right" class="left_txt2"><font size="2px">FTP地址：</font></td>
		                <td width="3%">&nbsp;</td>
		                <td align="left">
		                      <textarea id="strFtpAddress" name="strFtpAddress"   class="input_box" rows="5" cols="25"/></textarea>
		            </td> </tr>
		            <tr>
		               <td width="35%" height="30" align="right" ></td>
		                <td width="3%">&nbsp;</td>
		                <td align="left" ><font size="2px" color="red">注：请以“IP,用户名,密码”格式输入FTP地址</font></td>
		                 </tr>
		            <tr>
                      <td width="35%" height="30" align="right" class="left_txt2"><font size="2px">一级热点：</font></td>
                       <td width="3%">&nbsp;</td>
                       <td align="left">
                       <input id="strClassOneHP" name="strClassOneHP" type="text" value="" class="input_box" size="30" onfocus="testMessageBox(this)" /></td>
                       <td> <input id="strHotSpotId" name="strHotSpotId" type="hidden" value="" /></td>
                
                    </tr>
                    <tr>

                    <td width="35%" height="30" align="right" class="left_txt2" ><font size="2px">二级热点：</font></td>
                    <td width="3%">&nbsp;</td>
                    <td  align="left">
			              <select id="strHotPotName" name="strHotPotName"   style="width:215px"  class="sel1" onfocus="getAcName1()" ><option value=''>- - - - -请选择- - - - -</option>
			                   <% for (int j = 0; j <  classOneList.size(); j++) {
								String city = (String)(classOneList.get(j)[0]);
								if(classOneAc!= null && classOneAc.equals(city))
								{
									ArrayList<String> coutryList = (ArrayList<String>)(classOneList.get(j)[1]);
									for(int k =0;k<coutryList.size();k++)
									{
										String selected = "";
										if(coutryList.get(k)!=null && coutryList.get(k).equals(classTwoAc))
											selected="selected='selected'";
					
							%>
							<option value="<%=coutryList.get(k)%>" <%=selected%>>
								<%=coutryList.get(k)%>
							</option>
							<%
									}
								}
							}
							%>             
			         </select>
			         </td>
                   </tr>
		            <tr> 
		              <td width="35%" height="30" align="right" class="left_txt2"><font size="2px">自动下发AP：</font></td>
                      <td width="3%">&nbsp;</td>
                      <td align="left"height="30">
                      <input  type="checkbox" value="1"  id="intIssued" name="intIssued" /><font size="2px"></font><br/>
                       </td>
                       </tr>
             </table >
            </td>
            <td>
            <table width="365" border="0" cellspacing="0" cellpadding="0" height="502">
		            <tr>
						<td width="35%" height="30" align="right" class="left_txt2" ><font size="2px">选择人员：</font></td>
		             	<td width="3%">&nbsp;</td>
		                <td align="left">
		        		<label><font size="3" color="red">
		        		<input type="button" name="add" value="选择测试人" onclick="openwindow()"/></font></label>
		        		</td>
		              </tr>
		              <tr>
				         <td width="35%" height="30" align="right" class="left_txt2"><font size="2px">任务名称：</font></td>
				         <td width="3%">&nbsp;</td>
				         <td width="40%" align="left"><input type="text"  class="ipt" name="strTaskName" id="strTaskName"/>
				         </td> 
				        </tr>
				      <tr>
			             <td width="35%" height="30" align="right" class="left_txt2" ><font size="2px">任务类型 ：</font></td>
			             <td width="3%">&nbsp;</td>
			            <td width="40%" height="30">
			            
			            <select id="strTaskType" name="strTaskType"   style="width:215px"  class="input_box"  >
			            <option value=''>- - - - -请选择- - - - -</option>
			             <%
			                    for (int i = 0;i < vctObj2.size(); i++) {
			                    Testtemplate obj3 = vctObj2.get(i);
			              %>
			                <option value="<%=obj3.getStrTemplateName()%>"><%=obj3.getStrTemplateName()%></option>
			              <%
			                  }
			              %>      
						                             
			         </select></td>
		           </tr>
		           <tr>
			             <td width="35%" height="30" align="right" class="left_txt2" ><font size="2px">网络类型 ：</font></td>
			             <td width="3%">&nbsp;</td>
			            <td width="40%" height="30">
			            
			            <select id="strNetType" name="strNetType"   style="width:215px"  class="input_box"  >
			            <option value=''>- - - - -请选择- - - - -</option>
			               <%
			                  //从全局变量中读取参数类型
			                  String netType = (String)application.getAttribute("NET_TYPE");
			                  String[] netTypes = netType.split(",");
			                  for (int i = 0; i < netTypes.length; i++) {
			              %>
			                <option value="<%=netTypes[i]%>"><%=netTypes[i]%></option>
			              <%
			                  }
			              %>                 
			         </select></td>
		           </tr>
		           <tr>
				         <td width="35%" height="30" align="right" class="left_txt2"><font size="2px">测试次数：</font></td>
				         <td width="3%">&nbsp;</td>
				         <td width="40%" align="left"><input type="text"  class="ipt" name="strTestCount" id="strTestCount"/>
				         </td> 
				    </tr>
				    <tr>
				        <td width="35%" height="30" align="right" class="left_txt2"><font size="2px">HTTP地址：</font></td>
				        <td width="3%">&nbsp;</td>
				        <td align="left">
				        <textarea id="strHttpSite" name="strHttpSite"   class="input_box" rows="5" cols="25"/></textarea>
				     </td> </tr>
				     <tr>
				        <td width="35%" height="30" align="right" class="left_txt2"><font size="2px">备注：</font></td>
				        <td width="3%">&nbsp;</td>
				        <td align="left">
				        <textarea id="strRemark" name="strRemark"   class="input_box" rows="5" cols="25"/></textarea>
				     </td> </tr>
				     <tr>
		              <td width="35%" height="30" align="right" class="left_txt2"><font size="2px">时限开始：</font></td>
		              <td width="3%">&nbsp;</td>
		              <td align="left">
	          			<input  name="dtStartTime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});" class="input_box" value="<%="" %>"/>
	          		  </td>
		            </tr>
				     <tr>
				        <td width="35%" height="30" align="right" class="left_txt2"><font size="2px">时限结束：</font></td>
				        <td width="3%">&nbsp;</td>
				        <td align="left">
			          	<input  name="dtEndTime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});" class="input_box" value="<%="" %>"/>
			          	</td>
				     </tr>
				     
		              
            </table>
            </td>
            </tr>
            </table>
           <table width="832" border="0" cellspacing="0" cellpadding="0" height="35">
              <tr>
               <td width="3%" >&nbsp; <br></td>
              <td width="40%" height="20" align="right"> <input name="B1" type="button"   value="确  定" onclick="chkFrm()"  class="ipt2" /></td>
               <td width="3%" >&nbsp; <br></td>
               <td width = "6%"><input type="button"  onclick="window.location.href='task_list.jsp';" value="返 回" class="ipt2" style="cursor:hand"/></td>
               
               <td width="3%" >&nbsp; <br></td>
               <td width="32%" height="20"><input  name="B12" type="reset"  value="取 消" class="ipt2" /></td>
               <td height="30" class="left_txt2">&nbsp;</td>               
            </tr> 
            </table>
            </td>
          </tr>
        </table>
  
</td>
  </tr>
 
</table>
 </div>
<p><br />
</p>
    </form>
 
</body>
</html>
<%@ include file="../include/jsp/footer.jsp"%>
